const {Controller}=require("egg")

class Ping extends Controller{
    async ping(){
        const {ctx}=this
        const id=ctx.args[0]
        const result=await ctx.app.mysql.query(`select * from article where article_id="${id}"`)
        let count=result[0].count
        count++
        const sql=`update article set count=? where article_id=?`
        await this.app.mysql.query(sql,[count,id])
        this.app.io.of("/").emit("getCount",count)
    }
}

module.exports=Ping